package cn.wolfcode.rbac.web.controller;

import cn.wolfcode.rbac.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Description TODO
 * @ClassName LoginController
 * @Author luhui
 * @date 2020.06.14 02:59
 * @version: 1.0
 */
@Controller
public class LoginController {

    @Autowired
    private IEmployeeService employeeService;

    @RequestMapping("/login")
    public String login(String name, String password, Model model){
        try {
            employeeService.login(name,password);
            return "redirect:/department/list.do";
        }catch (Exception e){
            e.printStackTrace();
            model.addAttribute("errorMsg",e.getMessage());
            return "forward:/login.jsp";
        }
    }
}